package web.suzy.oj.controller.file;

import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import web.suzy.oj.service.file.UserFileService;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * YangSuzy 软件工作室
 * 类名: UserFileController
 * 描述: ---- 待定 -----
 * 功能: ---- 待定 -----
 *
 * @author YangSuzy
 * Date: 2022/11/28 13:49
 */
@Controller
@RequestMapping("/api/file")
public class UserFileController {
    @Autowired
    private UserFileService userFileService;

    /**
     * 方法名: generateUserExcel
     * 描述: 生成用户信息Excel表
     *
     * @param key      缓存 Key
     * @param response 响应
     * @return void
     * @date 2022/11/28 13:49
     * @auther YangSuzy
     **/
    @RequestMapping("/generate-user-excel")
    @RequiresAuthentication
    @RequiresRoles("root")
    public void generateUserExcel(@RequestParam("key") String key, HttpServletResponse response) throws IOException {
        userFileService.generateUserExcel(key, response);
    }
}
